package ModelLayer;

import java.io.Serializable;
import java.text.DecimalFormat;

public class Group implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private static int lastId = 0;
	private int id;
	private int paymentTerm;
	private double craftmanDiscount;
	private double quantityDiscount;
	private double pickUpDiscount;
	
	public Group(int paymentTerm, double craftmanDiscount, double quantityDiscount, double pickUpDiscount) throws RealException 
	{
		this.id=generateId();
		this.paymentTerm=paymentTerm;
		this.craftmanDiscount=craftmanDiscount;
		this.quantityDiscount=quantityDiscount;
		this.pickUpDiscount=pickUpDiscount;
	}

	public int getId() {
		return id;
	}

	public double getPickUpDiscount() {
		return pickUpDiscount;
	}

	public void setPickUpDiscount(double pickUpDiscount) {
		this.pickUpDiscount = pickUpDiscount;
	}

	public void setId(int id) {
		this.id = id;
	}

	public int getPaymentTerm() {
		return paymentTerm;
	}

	public void setPaymentTerm(int paymentTerm) {
		this.paymentTerm = paymentTerm;
	}

	public double getCraftmanDiscount() {
		return craftmanDiscount;
	}

	public void setCraftmanDiscount(double craftmanDiscount) {
		this.craftmanDiscount = craftmanDiscount;
	}

	public double getQuantityDiscount() {
		return quantityDiscount;
	}

	public void setQuantityDiscount(double quantityDiscount) {
		this.quantityDiscount = quantityDiscount;
	}
	
	public int generateId()
	{
		return ++lastId;
	}
	
	public static int getLastId()
	{
		return lastId;
	}
	
	public static void setLastId(int lastid)
	{
		lastId = lastid;
	}
	
	public String toString()
	{
		return "Id: " + getId() + "\n Payment Term: " + getPaymentTerm() + "\n CraftmanDiscount: " + Double.valueOf(new DecimalFormat("#.##").format(getCraftmanDiscount() * 100)) + "%\n Quantity Discount: " + Double.valueOf(new DecimalFormat("#.##").format(getQuantityDiscount() * 100)) + "%\n Pick Up Discount " + Double.valueOf(new DecimalFormat("#.##").format(getPickUpDiscount() * 100)) + "%";
	}
	
}
